﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using YTCMS.Core;
using YTCMS.Core.YTModelBinder;

namespace YTCMS.Services
{
    public interface IBaseService<T> where T : class
    {
        T Add(T t);
        T Get(Expression<Func<T, bool>> where);
        T Get(Expression<Func<T, bool>> where, bool NoTracking);
        IQueryable<T> GetMany(Expression<Func<T, bool>> where);
        void Update(T t);
        void Delete(T user);
        void Delete(Expression<Func<T, bool>> where);
        IQueryable<T> PageList(int pageIndex, int pageSize, out int pcount);

        IQueryable<T> PageList(IQueryable<T> t, int pageIndex, int pageSize, out int pcount);

        IQueryable<T> PageList(SearchModel searchModel, int pageIndex, int pageSize, out int pcount);
        IQueryable<T> PageList(Expression<Func<T, bool>> where, int pageIndex, int pageSize, out int pcount);

        IEnumerable<T> GetMany(Expression<Func<T, bool>> where, string includeName);

        IEnumerable<T> GetMany(bool noTracking, Expression<Func<T, bool>> where);
        IEnumerable<T> GetAsyncMany(Expression<Func<T, bool>> where);
        T GetAsync(Expression<Func<T, bool>> where);
        object ExecuteScalar(string sql);
        int ExecuteSqlCommand(string sql, params object[] obj);
        IQueryable<T> GetMany(Expression<Func<T, bool>> where, Order orderBy, string orderFile);
    }
}
